package com.huisheng.mapper;

import com.huisheng.pojo.Order;
import com.huisheng.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Authther: mrwu
 * @date:2021/3/5-03
 * @Description:com.huisheng.mapper
 */
public interface OrderMapper {
    List<Order> findAll();

//    //注解一对一开发
    @Select("select * from orders")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "ordertime",column = "ordertime"),
            @Result(property = "total",column = "total"),
            @Result(property = "user",column = "uid",javaType = User.class,
                    one=@One(select = "com.huisheng.mapper.UserMapper.findById"))
    })
    List<Order> findOrderandUser();
    //根据uid 返回对应的订单集合
    @Select("select * from orders where uid=#{uid}")
    List<Order> findOrderByUid(int id);

}
